
PK2CMD = pk2cmd -PPIC18F2550
#PROCESSOR = 18f2550
PROCESSOR = 18f2455

GPLINK_INCLUDE_DIR = -I"/usr/bin/../share/sdcc/lib/pic16" -I"/usr/share/sdcc/lib/pic16" -I"/usr/bin/../share/sdcc/lib" -I"/usr/share/sdcc/lib"
SDCC_INCLUDE_DIR = "-I/usr/share/sdcc/include"
SDCC_LIB_DIR = "-L/usr/share/sdcc/lib/pic16"

# on imac...
#GPLINK_INCLUDE_DIR = 	-I"/opt/local/bin/../share/sdcc/lib/pic16" -I"/opt/local/share/sdcc/lib/pic16" -I"/opt/local/bin/../share/sdcc/non-free/lib/pic16" -I"/opt/local/share/sdcc/non-free/lib/pic16"
#SDCC_INCLUDE_DIR = -I/opt/local/share/sdcc/non-free/include -I/opt/local/share/sdcc/non-free/include/pic16 -I/opt/local/share/sdcc/non-free/include -I/opt/local/share/sdcc/include/pic16
#SDCC_LIB_DIR = "-L/opt/local/share/sdcc/lib/pic16 -L/opt/local/share/sdcc/lib/small-stack-auto"

all:	stepper_test

stepper_test: stepper_test.c
	sdcc \
	--verbose \
	-V \
	--debug \
	-mpic16 \
	-I"./" \
	--use-crt=crt0.o \
	--use-non-free \
	-p$(PROCESSOR) $<

stepper_test.hex: stepper_test.o
	gplink \
	-c \
	-o $@ \
	-m \
	-r \
	$(GPLINK_INCLUDE_DIR) \
	-I"./" \
	crt0.o libdev18f2455.lib libsdcc.lib libc18f.lib libio18f2455.lib \
	$^
#	-s 18f2550.lkr \


stepper_test.o: stepper_test.asm
	gpasm \
	--extended \
	-pp$(PROCESSOR) \
	-c $<

stepper_test.asm: stepper_test.c
	sdcc \
	$(SDCC_INCLUDE_DIR) \
	$(SDCC_LIB_DIR) \
	-S \
	--debug \
	-mpic16 \
	--mplab-comp \
	--use-crt=crt0.o \
	--use-non-free \
	-p$(PROCESSOR) $<

clean:
	rm -f *.adb *.asm *.cod *.cof *.hex *.lst *.map *.o *.sym *.lib

sim:
	/usr/local/bin/gpsim -pp$(PROCESSOR) -c stepper_test.stc -s stepper_test.cod stepper_test.asm

flash:
	$(PK2CMD) -F stepper_test.hex -M

#-Y

on:
	$(PK2CMD) -R -T

